package com.feeling.oafeeling.service.impl;

import com.feeling.oafeeling.mapper.FlOrderMapper;
import com.feeling.oafeeling.pojo.FlOrder;
import com.feeling.oafeeling.pojo.FlOrderExample;
import com.feeling.oafeeling.service.IFlOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by IntelliJ IDEA.
 *
 * @Author : LiuLi
 * @create 2023/6/21 21:58
 */
@Service
public class FlOrderServiceImpl implements IFlOrderService {

    @Autowired
    private FlOrderMapper flOrderMapper;

    @Override
    public List<FlOrder> getAllTasksList() {
        return flOrderMapper.selectAllTaskList();
    }

    @Override
    public long getAllCountNum() {
        return flOrderMapper.countByExample(new FlOrderExample());
    }

    @Override
    public String findOrderNum(int taskId) {
        return flOrderMapper.findOrderNum(taskId);
    }

    @Override
    public Integer findStepId(int taskId, String orderStatus) {
        int step = 0;
        if ("START".equals(orderStatus)){
            step = 1;
        }else if (!"OVER".equals(orderStatus)){
            step = Integer.valueOf(orderStatus);
        }
        return flOrderMapper.findIfHaveStepId(taskId,step);
    }
}
